home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 583 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.0 KB

  1. Path: solon.com!not-for-mail
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c.moderated,comp.std.c
  4. Subject: Re: 'h' modifier in printf
  5. Date: 16 Mar 1996 21:17:18 -0600
  6. Organization: CERN European Lab for Particle Physics
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4ig07u$fsp@solutions.solon.com>
  10. References: <4i801c$455@solutions.solon.com> <4iepq6$af6@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12. X-Newsreader: NN version 6.5.0 #7 (NOV)
  13.  
  14. In <4iepq6$af6@solutions.solon.com> gordon@sneaky.lerctr.org (Gordon Burditt) writes:
  15.  
  16. >I don't think so, BUT:
  17. >short s = -1;
  18. >printf("%x\n", (unsigned int) s);
  19. >printf("%hx\n", (unsigned int) s);
  20. >
  21. >/* is it allowed to leave out the casts? */
  22.  
  23. In practice, yes (any int value is likely to have a meaning as unsigned
  24. int as well and they have the same size).  Strictly speaking, leaving out
  25. the cast invokes undefined behaviour, however.
  26.  
  27. Dan
  28. --
  29. Dan Pop
  30. CERN, CN Division
  31. Email: danpop@mail.cern.ch 
  32. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  33.